package indi.gao.option;

import com.alibaba.fastjson.JSONObject;
import indi.gao.model.Apple;
import org.junit.Test;

import java.util.Optional;

/**
 * @author :gaolei
 * @version :v1.0
 * @projectName :GLUtil
 * @description :
 * @createDate :2021/5/22 9:56 上午
 */
public class OptionTest {

    @Test
    public void testNullObject() {
        Apple apple = null;
        Optional.ofNullable(apple).ifPresent(x -> System.out.println(JSONObject.toJSONString(x)));
        apple = new Apple();
        Optional.of(apple).ifPresent(x -> System.out.println(JSONObject.toJSONString(x)));
    }
}
